package com.springboot.erp.mapper;

import com.springboot.erp.entity.JshAccountHead;
import com.springboot.erp.entity.ReceiptDTO;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface ReceiptMapper {
        ReceiptDTO selectReceiptById(@Param("id") Long id);
        List<JshAccountHead> selectReceiptList(
                @Param("organId") Long organId,
                @Param("status") String status,
                @Param("startDate") Date startDate,
                @Param("endDate") Date endDate
        );

        @Insert("insert into jsh_account_head(type, organ_id, hands_person_id," +
                " creator, change_amount, discount_money, total_price, account_id, " +
                "bill_no, bill_time, remark, file_name, status, source, tenant_id, delete_flag) " +
                "values ('收款', #{organId}, #{handsPersonId}, #{creator}, #{changeAmount}, " +
                "#{discountMoney}, #{totalPrice}, #{accountId}, #{billNo}, #{billTime}, #{remark}, " +
                "#{fileName}, #{status}, #{source}, #{tenantId}, #{deleteFlag})")
        void insertOne(JshAccountHead jshAccountHead);
        @Update("update jsh_account_head set  organ_id = #{organId}, hands_person_id = #{handsPersonId}," +
                "creator = #{creator}, change_amount = #{changeAmount}, discount_money = #{discountMoney}," +
                "total_price = #{totalPrice}, account_id = #{accountId}, bill_no = #{billNo}, bill_time = #{billTime}," +
                "remark = #{remark}, file_name = #{fileName}, status = #{status}, source = #{source}," +
                "tenant_id = #{tenantId}, delete_flag = #{deleteFlag} where id = #{id} and type = '收款'")
        void updateOne(JshAccountHead jshAccountHead);

        @Delete("delete from jsh_account_head where id = #{id} and type = '收款'")
        void deleteOne(@Param("id") Integer id);

    }

